set_mm_mapping() may fail because of xc_domain_populate_physmap(). In
this case, we should not blindly go on; the xc_map_foreign_batch()
that follows will cause a page fault and, at best, get mapped in a
zeroed page from the dom0 (which is not what we want). While I'm in
here, fix a memory leak on an error path.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
for (i = 0; i < nr_extents; i++)
extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
- set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+ if (set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start) < 0) {
+ fprintf(logfile, "Failed set_mm_mapping\n");
+ free(extent_start);
+ return NULL;
+ }
vram_pointer = xc_map_foreign_batch(xc_handle, domid,
PROT_READ|PROT_WRITE,
if (vram_pointer == NULL) {
fprintf(logfile, "xc_map_foreign_batch vgaram returned error %d\n",
errno);
+ free(extent_start);
return NULL;
}